//
//  OosPrivacy.m
//  Oos4ios
//
//  Created by Pablo Gonzalez on 3/9/11.
//  Copyright 2011 11870.com. All rights reserved.
//

#import <oos4ios/Model/OosPrivacy.h>
#import "../../Macros/EnumMacros.h"
#import "../../Utils/OosEnum+Internal.h"

@implementation OosPrivacy

OosEnumValues(privacy,  OOS_PRIVACY_PUBLIC_KEY, 
                        OOS_PRIVACY_CONTACTS_KEY, 
                        OOS_PRIVACY_TRUSTED_KEY, 
                        OOS_PRIVACY_PRIVATE_KEY, 
                        OOS_PRIVACY_DRAFT_KEY);

OosEnumDictionary(privacy);

OosEnumGetter(OosPrivacy *, publicPrivacy, OOS_PRIVACY_PUBLIC);
OosEnumGetter(OosPrivacy *, contacts, OOS_PRIVACY_CONTACTS);
OosEnumGetter(OosPrivacy *, trustedContacts, OOS_PRIVACY_TRUSTEDCONTACTS);
OosEnumGetter(OosPrivacy *, privatePrivacy, OOS_PRIVACY_PRIVATE);
OosEnumGetter(OosPrivacy *, draft, OOS_PRIVACY_DRAFT);

static NSArray *parseValues = nil;

+ (NSArray *)parseValues
{
    if (!parseValues) {
        parseValues = [[NSArray arrayWithObjects: @"public", @"contacts", @"trustedcontacts", @"private", @"draft", nil] retain];
    }
    return parseValues;
}

+ (id) enumFromLiteral: (NSString *) literal
{
    id result = [super enumFromLiteral: literal];
    
    if (!result) {
        NSArray *parseValues = [self parseValues];
        NSUInteger index = [parseValues indexOfObject:literal];
        result = [self enumForPosition:index];
    }
    return result;
}

- (NSString *)description
{
    return [[[self class] parseValues] objectAtIndex:self.ordinal];
}

@end
